package com.itheima.controller.oms;


import com.itheima.core.PageInfo;
import com.itheima.core.R;
import com.itheima.pojo.oms.OmsOrderReturnReason;
import com.itheima.pojo.oms.vo.IdStatusVo;
import com.itheima.pojo.oms.vo.IdsVo;
import com.itheima.pojo.oms.vo.returnReason;
import com.itheima.service.oms.OmsOrderReturnReasonSrevice;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/returnReason")
public class OmsOrderReturnReasonController {
    @DubboReference
    private OmsOrderReturnReasonSrevice omsOrderReturnReasonSrevice;


    /*添加退货原因*/
    @PostMapping("/create")
    public R create(@RequestBody OmsOrderReturnReason returnReason){

        omsOrderReturnReasonSrevice.create(returnReason);
        return R.success();
    }
    /*批量删除退货原因*/
    @PostMapping("/delete")
    public R deletes(@RequestParam  List<Integer> ids){
        omsOrderReturnReasonSrevice.removeByIds(ids);
        return R.success();
    }

    /*分页查询退货原因*/
    @GetMapping("/list")
    public R listAll(@RequestParam int  pageNum, @RequestParam int  pageSize){
       PageInfo info=omsOrderReturnReasonSrevice.listAll(pageNum,pageSize);
       return R.success("",info);
    }
    /*修改退货原因启用状态*/
    @PostMapping("/update/status")
    public R updatestatus(Integer ids,Integer status){
        omsOrderReturnReasonSrevice.updatestatus(ids,status);
        return  R.success();
    }
    /*修改退货原因*/
    @PostMapping("/update/{id}")
    public R UpdateId(@PathVariable int id,@RequestBody returnReason returnReason){
        omsOrderReturnReasonSrevice.UpdateId(id,returnReason);
        return R.success();
    }
    /*获取单个退货原因详情信息*/
    @GetMapping("/{id}")
    public R getId(@PathVariable int id){
        OmsOrderReturnReason byId = omsOrderReturnReasonSrevice.getById(id);
        return R.success("",byId);
    }
}
